@extends('layouts.master')
@section('content')

        <div class="col-lg-12">
                <div class="card card-table">
                        <div class="card-header">
                                分类管理
                        </div>
                        <div class="xs-mt-30 xs-mb-20 text-center">
                                <a href="" class="btn btn-space btn-success md-trigger">分类列表</a>
                                <button data-toggle="modal" data-target="#addCategory" type="button" class="btn btn-space btn-primary">添加用户</button>
                        </div>
                        @component('components.modal',['title'=>'添加分类','url'=>'/shop/category','id'=>'addCategory'])
                                <div class="form-group">
                                        <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">分类名称</font></font></label>
                                        <input type="text" name="cname" class="form-control">
                                </div>
                                <div class="form-group">
                                        <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">父级分类</font></font></label>
                                        <div class="form-group row pt-1">
                                                <div class="col-12 col-sm-12 col-lg-12">
                                                        <select class="form-control" name="pid">
                                                                <option value="0" selected="">顶级分类</option>
                                                                @foreach($category as $v)
                                                                <option value="{{$v['id']}}">{{$v['cname']}}</option>
                                                                @endforeach
                                                        </select>
                                                </div>
                                        </div>
                                </div>

                        @endcomponent
                        <div class="card-body">

                                <table class="table">
                                        <thead>
                                        <tr>
                                                <th>编号</th>
                                                <th>分类名称</th>
                                                <th>父级分类</th>
                                                <th class="actions">操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        @foreach($category as $v)
                                                <tr>
                                                        <td>{{$v['id']}}</td>
                                                        <td>{{$v['_cname']}}</td>
                                                        <td>{{$v['pid']}}</td>
                                                        <td class="actions">
                                                                <div class="btn-group btn-space">
                                                                        <a href="{{route('category.edit',$v['id'])}}" class="btn btn-space btn-primary">编辑</a>

                                                                        @component('components.modal',['title'=>'编辑用户','url'=>'','id'=>'','method'=>'PUT'])
                                                                                <div class="form-group text-left">
                                                                                        <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">分类名称</font></font></label>
                                                                                        <input type="text" name="name" value="" class="form-control">
                                                                                </div>
                                                                                <div class="form-group text-left">
                                                                                        <label><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">父级分类</font></font></label>
                                                                                        <input type="text" name="nickname" value="" placeholder="请输入用户昵称..." class="form-control">
                                                                                </div>

                                                                        @endcomponent
                                                                        <form action="{{route('category.destroy',$v['id'])}}" method="post">
                                                                                @csrf
                                                                                @method('delete')
                                                                                <button type="submit" class="btn btn-danger">删除</button>
                                                                        </form>
                                                                </div>
                                                        </td>
                                                </tr>
                                        @endforeach
                                        </tbody>
                                </table>
                        </div>
                </div>
        </div>

@endsection